﻿using Shell.DomainDot;
using Framework.Poco;
using System;

namespace Framework.Domain
{
    /// <summary>
    /// 广告和图片的上下文
    /// </summary>
    public class AdvertisingAndPictureContext : DomainDotBase<Advertising>
    {
        /// <summary>
        /// 属于链接的文件
        /// </summary>
        public WithOne<BinaryFile> BinaryFileBelonged { private get; set; }

        /// <summary>
        /// 获取链接的的文件
        /// </summary>
        public Guid GetBinaryFileIdentity()
        {
            return this.BinaryFileBelonged.Instance.Id;
        }

        /// <summary>
        /// 绑定文件
        /// </summary>
        public void BindBinaryFile(Guid identity)
        {
            this.BinaryFileBelonged.Bind(identity);
            this.BinaryFileBelonged.Submit();
        }

        /// <summary>
        /// 删除文件
        /// </summary>
        public void Delete()
        {
            this.BinaryFileBelonged.Delete();
            this.BinaryFileBelonged.Submit();
        }
    }
}
